#ifndef SL_SINGLETON_HPP
#define SL_SINGLETON_HPP

#define NULL 0

namespace sl
{
	template <typename S>
	class Singleton
	{
	protected:
		Singleton() {}

		virtual ~Singleton()
		{
			delete myInstance;
			myInstance = NULL;
		}

	protected:
		static S* myInstance;

	public:
		static S* GetInstance()
		{
			if (!myInstance)
				myInstance = new S();

			return myInstance;
		}
	};

	template <typename S> S* Singleton<S>::myInstance = NULL;
}

#endif //SL_SINGLETON_HPP